package com.example.famhealing.schedule;

import java.util.Calendar;

import com.example.famhealing.R;

import android.app.DatePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;

public class ScheduleActivity extends FragmentActivity{

	ImageButton backButton;
	ImageButton confirmButton;
	
	public static int selectedYear;
	public static int selectedMonth;
	public static int selectedDay;
	
	String time, phoneNum, memo, dosage, condition, weight, temper, rate, pressure, sideEffects;
	
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_schedule);
        
        Intent intent = getIntent();
        selectedYear = (Integer) intent.getExtras().get("selectedYear");
        selectedMonth = (Integer) intent.getExtras().get("selectedMonth");
        selectedDay = (Integer) intent.getExtras().get("selectedDay");
        
        if(TopFragment.state==1) {
        	time = CalendarPopup.date;
        	memo = SetMemo.memo;
        	condition = Integer.toString(SetCondition.value);
        	rate = Integer.toString(SetRatePressure.tempRate);
        	pressure = Integer.toString(SetRatePressure.tempPressure);
        	weight = Double.toString(SetWeightTemper.tempWeight);
        	temper = Double.toString(SetWeightTemper.tempTemper);
        	sideEffects = SetSideEffects.sideEffects;
        }
        
        backButton = (ImageButton) findViewById(R.id.backButton);
        backButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
        	
        });
        
        confirmButton = (ImageButton) findViewById(R.id.confirmButton);
        confirmButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(TopFragment.state==1) {
					//new AddDiarySchedule().execute();
				} else {
					
				}
			}
        	
        });
        
    }
	
	/*
    private class AddDiarySchedule extends AsyncTask<Void, Void, String> {	

		@Override
		protected String doInBackground(Void... params) {
			// TODO Auto-generated method stub
			
			String url = "http:// 54.250.182.202:8080/famhealing/setDiarySchedule.set?time=날짜시간&phone_num=전화번호"
		
			String error = "";
			
			try {
				
				//Post				
				
				URL urladdr = new URL(url);
				
				//Parsing
				boolean inTitle1 = false;
		  			
		  		XmlPullParserFactory parserCreator = XmlPullParserFactory.newInstance();
		  			
		  		XmlPullParser parser = parserCreator.newPullParser(); 
		  		parser.setInput(urladdr.openStream(), "UTF-8");
		  		
		  		int parserEvent = parser.getEventType(); 
		  		
		  		String tag;
		  		
		  		while(parserEvent != XmlPullParser.END_DOCUMENT) {
		  			switch(parserEvent) {
		  			case XmlPullParser.START_DOCUMENT:
		  				break;
		  			case XmlPullParser.END_DOCUMENT:
		  				break;
		  			case XmlPullParser.START_TAG:
		  				tag = parser.getName();
		  				if(tag.equals("error")) {
		  					inTitle1 = true;
		  				}
		  				break;
		  			case XmlPullParser.TEXT:
		  				//tag = parser.getName();
		  				if(inTitle1) {
		  					error = parser.getText();
		  					inTitle1 = false;
		  				}
		  				break;
		  			case XmlPullParser.END_TAG:
		  				break;
		  			}
		  			parserEvent = parser.next();	
		  		}
		  			
		  	} catch (Exception e) {
		  			Log.e("dd", "Error in network call", e);
		  	}
			
			return error;
		}
		
		protected void onPostExecute(String error) {
			
			if(error.equals("0")){
				
				Toast.makeText(AddMeditationActivity.this, "일정 추가 성공!", Toast.LENGTH_SHORT).show();
			} else {
				Toast.makeText(AddMeditationActivity.this, "일정 추가 실패!", Toast.LENGTH_SHORT).show();
			}
			
			super.onPostExecute(error);
		}
	}
	*/

	
	
}
